package com.xingjiejian.feature.function;

/**
 * 演示4 种不同方法的引用
 * @author XingJiejian
 * @date 2019/5/7
 *
 * <code>@FunctionalInterface</code>
 * 函数式接口就是一个有且仅有一个抽象方法，但是可以有多个非抽象方法的接口。
 */
@FunctionalInterface
public interface Supplier<T> {
    T get();
}

class Car{
    public static Car create(final Supplier<Car> supplier) {
        return supplier.get();
    }

    public static void collide(final Car car) {
        System.out.println("Collided " + car.toString());
    }

    public void follow(final Car another) {
        System.out.println("Following the " + another.toString());
    }

    public void repair() {
        System.out.println("Repaired " + this.toString());
    }
}
